//== SAGITTARIUS ============================================================================

//== BEGINNING OF CODE ===============================================================

#ifndef __SAGUTTARUIS__RADIXTREE__H_
#define __SAGUTTARUIS__RADIXTREE__H_

//== INCLUDES ========================================================================

#include "sagittarius/core/SagittariusCore.h"
#include "sagittarius/lexer/lexcore.h"
#include "sagittarius/unicode/CUnicode.h"
#include "sagittarius/parallel/multisema.h"
#include <stddef.h>

#define RADIXTREE_DEFAULT_NEDGES 16

#ifdef __cplusplus
extern "C" {
#endif

typedef struct __radixnode {
    struct __radixnode** edges;
    size_t nedges;
    size_t sz;
    LexBuf label;
    size_t labellen; //includes null-terminating char
    int terminal;
    
    void *p; //data
} radixnode;

radixnode* radix_get(radixnode* n, constLexBuf label);

 //NOTE: important: label must be null-terminated
int radix_search_and_add(radixnode* root, constLexBuf label, void* p);

//creation/destruction
radixnode* create_radix_root();
void destroy_radix_node(radixnode* n);

void dump_radix_node(const int fd, radixnode* n, int ind);

#ifdef __cplusplus
}//extern "C"
#endif

#endif
